package redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.List;
import java.util.Set;

public class RedisDemoString {
    public static void test2(Jedis jedis) {
        System.out.println("getrange 和 setrange");
        jedis.flushAll();

        jedis.set("key","abcdefggggg");

        String value = jedis.get("key");
        System.out.println(value);
        value = jedis.getrange("key",3,5);
        System.out.println(value);
        jedis.setrange("key",3,"xyz");
        value = jedis.get("key");
        System.out.println(value);

    }
    public static void test1(Jedis jedis) {
        System.out.println("mset 和 mget");
        jedis.flushAll();

        jedis.mset("key1","111","key2","222","key3","333");

        List<String> values = jedis.mget("key2","key1","key22","key3");
        System.out.println(values);
    }


    public static void main(String[] args) {
        JedisPool jedisPool = new JedisPool("tcp://127.0.0.1:8888");
        try (Jedis jedis = jedisPool.getResource()) {
            //test1(jedis);
            test2(jedis);
        }
    }
}
